<?php
if(ISSET($_GET['file'])){
	$data = substr(substr($_GET['file'], 1, (strlen($_GET['file'])-1)), 0, -1);

	$data = explode("\"", $data);
	$l = sizeof($data) - 1;
	//echo $l;
	$m = array();
	for($i=1; $i < $l; $i = $i+2){
		array_push($m, str_replace("\\r\\n",PHP_EOL,str_replace("\/","/",$data[$i])));
	}

	$login = $m[0];
	$inter = $m[1];
	$char = $m[2];
	$map = $m[3];
	$readme = $m[4];

	$fname = "eAOCW.zip";

	$file1 = tempnam("tmp", "zip");
	$zip = new ZipArchive();

	if ($zip->open($file1, ZIPARCHIVE::CREATE) !== TRUE):
		trigger_error('Unable to create zip archive', E_USER_ERROR);
	endif;

	$zip->open($file1, ZIPARCHIVE::OVERWRITE);
	$zip->addEmptyDir('conf/import');
	$zip->addFromString('conf/import/login_conf.txt', $login);
	$zip->addFromString('conf/import/inter_conf.txt', $inter);
	$zip->addFromString('conf/import/char_conf.txt', $char);
	$zip->addFromString('conf/import/map_conf.txt', $map);
	$zip->addFromString('readme.txt', $readme);

	$zip->close();
	header("Content-Disposition: attachment; filename=\"".$fname."\"");
	header('Content-Length: ' . filesize($file1));
	readfile($file1);
	unlink($file1);	
} else{
	echo "Go back and click the Download button";
}

?>